<?php
namespace App\Admin\Api\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\AdminUser;

// 用户
class UserController extends BaseApiController
{

    public function __construct()
        {
            parent::__construct(new AdminUser());
        }

        /**
         * @desc 数据校验证规则
         * @param string $action 操作类型（store 创建数据，update 更新数据）
         * @return array
         */
        protected function getValidationRules(string $action): array
        {
            return [
                       'store' => [
                           [
                               'username' => 'required',
                               'password' => 'required',
                               'avatar' => 'required',
                           ],
                           [
                               'factory_code.required' => '加工厂编码不能为空',
                               'factory_name.required' => '加工厂名称不能为空',
                           ]
                       ],
                       'update' => [],
                   ][$action] ?? [];
        }

}
